﻿using HK.Core.GUIEx.Protocol.Attribute;
using HK.Core.Utils;
using UnityEngine;

namespace HK.Core.GUIEx.Attribute
{
    /// <summary>
    /// Attribute - GUI面板基础属性
    /// </summary>
    public abstract class GUIAttribute : PropertyAttribute, IGUIAttribute
    {

#region Options
        
        /// <summary>
        /// 选项
        /// </summary>
        public int Options { get; protected set; } = (int)GUIOperateOptions.None;
        
        /// <summary>
        /// 绘制背景
        /// </summary>
        public bool DrawBg => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.DrawBg);

        /// <summary>
        /// 只读
        /// </summary>
        public bool ReadOnly => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.ReadOnly);

        /// <summary>
        /// 可展开
        /// </summary>
        public virtual bool Expandable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Expandable);
        
        /// <summary>
        /// 最小化
        /// </summary>
        public bool Minimize => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Minimize);
		
        /// <summary>
        /// 最大化
        /// </summary>
        public bool Maximize => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Maximize);
        
        /// <summary>
        /// 可追加
        /// </summary>
        public bool Addable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Addable);
		
        /// <summary>
        /// 可移除
        /// </summary>
        public bool Removable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Removable);
        
        /// <summary>
        /// 可枷锁
        /// </summary>
        public bool Lockable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Lockable);
        
        /// <summary>
        /// 可编辑
        /// </summary>
        public virtual bool Editable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Editable) ||
                                        UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Addable) ||
                                        UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Removable);
        
        /// <summary>
        /// 可拖拽
        /// </summary>
        public bool Draggable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Draggable);
        
        /// <summary>
        /// 多行
        /// </summary>
        public bool MultiLine => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.MultiLine);
		
        /// <summary>
        /// 可点击
        /// </summary>
        public bool Clickable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Clickable);
        
        /// <summary>
        /// 成员资产
        /// <para>* true : 成员为资产对象</para>
        /// </summary>
        public bool MemberAsset => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.MemberAsset);
        
        /// <summary>
        /// 成员无标题
        /// </summary>
        public bool MemberNoCaption => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.MemberNoCaption);
        
        /// <summary>
        /// 成员可拖拽
        /// </summary>
        public bool MemberDraggable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.MemberDraggable);
        
        /// <summary>
        /// 成员唯一
        /// </summary>
        public bool MemberDistinct => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.MemberDistinct);
        
        /// <summary>
        /// 可检索
        /// </summary>
        public bool Searchable => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.Searchable);
        
        /// <summary>
        /// 按Property绘制
        /// </summary>
        public bool DrawProperty => UtilsBytes.CheckBytes(Options, (int)GUIOperateOptions.DrawProperty);

        /// <summary>
        /// 是否从Unity调用绘制标志位
        /// </summary>
        public bool DrawFromUnity { get; protected set; } = true;
        
#endregion

#region Caption

        /// <summary>
        /// 标题
        /// </summary>
        public string Caption { get; protected set; } = null;
        
        /// <summary>
        /// Tips
        /// <para>* 鼠标悬停显示Tips</para>
        /// </summary>
        public string Tips { get; protected set; } = null; 
        
        /// <summary>
        /// Icon
        /// </summary>
        public string Icon { get; protected set; } = null;

        /// <summary>
        /// 背景色
        /// </summary>
        public virtual Color BgColor => Color.clear;
        
#endregion
        
    }
}
